package com.tianlang.service.impl;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import com.tianlang.dao.IBaseDao;
import com.tianlang.service.IBaseManager;

/**
 * 
 * @author mchp
 *
 */
@Service("baseManager")
@SuppressWarnings({ "unchecked", "rawtypes" })
public class BaseManager implements IBaseManager {

	protected final Logger logger = Logger.getLogger(BaseManager.class);

	@Resource
	protected IBaseDao baseDao;

	public List getObjects(Class clazz) {
		return baseDao.findAll(clazz);
	}

	public Object getObject(Class clazz, Serializable id) {
		return baseDao.getObject(clazz, id);
	}

	public void saveObject(Object o) {
		baseDao.save(o);
	}

	public void updateObject(Object o) {
		baseDao.update(o);
	}

	public void removeObject(Class clazz, Serializable id) {
		baseDao.delete(clazz, id);
	}

	public void removeObject(Object o) {
		baseDao.delete(o);
	}

	public void saveOrUpdate(Object entity) {
		baseDao.saveOrUpdate(entity);
	}

	public void delete(String hql) {
		baseDao.delete(hql);
	}

	public String getConfigurationValue(String key) {
		return baseDao.getConfigurationValue(key);
	}

	public Integer getTotalSize(Class clz, Map searchMap) {
		return baseDao.getTotalSize(clz, searchMap, null);
	}

	public Integer getTotalSize(Class clz, Map searchMap, String groupColumn) {
		return baseDao.getTotalSize(clz, searchMap, groupColumn);
	}

	public void saveMerge(Object entity) {
		baseDao.saveMerge(entity);
	}

	public List getPaginationObjects(Class clz, int pageIndex, int pageSize, Map searchMap, Map searchClassMap,
			List compareColumns, List scs) {
		return baseDao.getPaginationObjects(clz, pageIndex, pageSize, searchMap, searchClassMap, compareColumns, scs);
	}

	public List getPaginationObjects(Class clz, int pageIndex, int pageSize, Map searchMap, Map searchClassMap,
			List scs) {
		return baseDao.getPaginationObjects(clz, pageIndex, pageSize, searchMap, searchClassMap, scs);
	}

	public List getPaginationObjectsByGroup(Class clz, int pageIndex, int pageSize, Map searchMap, Map searchClassMap,
			List scs, String groupColumn) {
		return baseDao.getPaginationObjects(clz, pageIndex, pageSize, searchMap, searchClassMap, scs, groupColumn);
	}

	public List getObjectsByParams(Class clz, Map searchMap, List scs) {
		return baseDao.getObjectsByParams(clz, searchMap, null, scs);
	}

	public List getObjectsByParams(Class clz, Map searchMap, Map searchClassMap, List scs) {
		return baseDao.getObjectsByParams(clz, searchMap, searchClassMap, scs);
	}

	public Object getObjectByParams(Class clz, Map searchMap) {
		return baseDao.getObjectByParams(clz, searchMap);
	}

	public Integer getPaginationObjects(Class clz, Map searchMap, Map searchClassMap, List compareColumns) {
		return baseDao.getPaginationObjects(clz, searchMap, searchClassMap, compareColumns);
	}

	public Integer getPaginationObjects(Class clz, Map searchMap, Map searchClassMap) {
		return baseDao.getPaginationObjects(clz, searchMap, searchClassMap);
	}

	public List getListByWhere(String where, Object[] objects, Integer start, Integer size) {
		return baseDao.getObjectsWhere(where, objects, start, size);
	}

	public Integer getCount(String where, Object[] values) {
		return baseDao.getTotalRecordCount(where, values);
	}

}
